# coding: utf-8
from application import db



class Wallet(db.Model):
    __tablename__ = 't_wallet'

    id = db.Column(db.BigInteger, primary_key=True, unique=True, comment='序号')
    name = db.Column(db.String(20), nullable=False, comment='钱包名称')
    balance = db.Column(db.Numeric(10, 2), comment='余额')
    useraddress = db.Column(db.String(50), nullable=False, unique=True, comment='持有人')
    blocknum = db.Column(db.Integer, comment='块高')
    blockHash = db.Column(db.String(200), unique=True, comment='块哈希')
    transactionhash = db.Column(db.String(200), unique=True, comment='交易哈希')
    created_time = db.Column(db.DateTime, nullable=False, comment='创建时间')
    updated_time = db.Column(db.DateTime, nullable=False, comment='更新时间')

    def to_json(self):
        item = self.__dict__
        if "_sa_instance_state" in item:
            del item["_sa_instance_state"]
        return item